package it.pecuswap.backend.services;

import it.pecuswap.backend.business.UserBusiness;
import it.pecuswap.backend.exceptions.EntityHomeException;
import it.pecuswap.commons.client.rest.interfaces.UserServiceInterface;
import it.pecuswap.commons.dto.UsersDTO;
import it.pecuswap.commons.exceptions.PecuswapRestException;

import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;

import org.apache.log4j.Logger;

/**
 * Implementazione dei servizi relativi all'utente. Rest entry point
 * @author Ruggiero
 *
 */

//TODO: verificare chiamate multithread

@Path("/")
public class UserService implements UserServiceInterface{
	
	private static final Logger LOGGER = Logger.getLogger(UserService.class);
	private UserBusiness userBusiness;
	
	public UserService(){
		this.userBusiness = new UserBusiness();
	}

	public UsersDTO findUserByUserName(@QueryParam("username") String userName) throws PecuswapRestException {
		try {
			return userBusiness.findUserByUserName(userName);
		} catch (EntityHomeException e) {
			throw new PecuswapRestException();
		}
    }
    
	@Override
	public UsersDTO complexExample(UsersDTO dummy) throws PecuswapRestException {
		dummy.setFirstname("dummyname");
		return dummy;
	}

}